<?php

require_once 'Basic.php';

class FormFieldEmail extends FormFieldType {
  
  public function __construct() {
    $this->htmlId = null;
    $this->size = 20;
    $this->htmlClass = "emailField";
  }
  
  public function clearHtmlClass() {
    $this->htmlClass = "emailField";
  }

  public function getHtml($name, $value) {
    return $this->commonHtml($name, $value);
  }

  public function validate($input) {
    if(preg_match("%^[^@]+@.+$%", $input) === 1) {
      return true;
    }
    else {
      return "Email deve seguir o formato nome@dom&iacute;nio. Foi passado " .
              "\"<span class='userInput'>${input}</span>\".";
    }
  }
  
}
